
import request, { request2 } from "../util"

// 判断是否存在用户
export function foundUser(phone: string) {
    //http://101.37.23.156:3333
    return request.post<any, axiosTypes<foundUserType | null>>('/app/finduser', {
        phone
    })
}

// 发送验证码
export function sentYzm(phone: string) {
    return request2.get<any, YzmTypes>('/captcha/sent', {
        params: {
            phone
        }
    })
}

// 注册
export function zhuCe(value: {
    Yzm: string;
    newpass: string;
    password: string;
    phone: string;
    username: string
}) {
    return request.post<any,axiosTypes<ZhuceSuccseType>>("/app/register", {
        phone:value.phone,
        username:value.username,
        password:value.password
    })

}

// 验证验证码
export function YZYzm(phone: string, captcha: string) {
    return request2.get<any, YzmTypes>("http://120.26.90.83:3000/captcha/verify", {
        params: {
            phone,
            captcha
        }
    })
}

// 登录
export function postLogin(phone:string,password:string){
    return request.post<any,loginsType>("/app/login",{
        phone,
        password
    })
}

// 获取token
export function getToken(phone:string){
    return request.post<any,tokenType>('/app/gettoken',{
        phone
    })
}

// 修改密码
export function changePass(phone:string,password:string){
    return request.post<any,axiosTypes<changePass>>("/app/changepass",{
        phone,
        password
    })
}

// 获取用户信息
export function getUserInfoData(){
    return request.get <any,axiosTypes<foundUserType>>("app/getuserinfo")
}

// 修改头像
export  function changeImg(flie:FormData){
    return request.post<any,uploadFileTypes>("/app/uplodafile",flie)
}

// 修改用户信息
export function changeUserInfo(data:foundUserType){
    return request.post<any,axiosTypes<changuserTypes>>('/app/changeuserinfo',data)
}
